using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing.Design;
using System.Collections;

using System.Windows.Forms;
using System.Drawing;
using Camalon.Drawing;
using Camalon.Drawing.Shapes;


namespace Camalon.Drawing.Design
{
	/// <summary>
	/// Summary description for PieDesigner.
	/// </summary>
	public class PieDesigner:ShapeDesigner
	{

		public override ShapeAdornment CreateAdornment(ISelectionService selectionService)
		{
			if( this.Component is Pie) return new PieAdornment((Pie)this.Component, selectionService);
			return base.CreateAdornment (selectionService);
		}


		public Pie Pie
		{

			get{ return (Pie)this.Component;}
		}

		private int _oldStartAngle;
		private int _oldSweepAngle;
		PropertyDescriptor	_propStartAngle		= TypeDescriptor.GetProperties(typeof( Pie ))["StartAngle"];
		PropertyDescriptor	_propSweepAngle		= TypeDescriptor.GetProperties(typeof( Pie ))["SweepAngle"];

		public override void BeginEditControlPoints( )
		{
			_oldStartAngle =Pie.StartAngle;
			_oldSweepAngle =Pie.SweepAngle;
			base.BeginEditControlPoints ( );
		}


		public override void EndEditControlPoints( )
		{
			int newStartAngle = Pie.StartAngle;
			this.Pie.StartAngle = _oldStartAngle;
			_propStartAngle.SetValue(Pie, newStartAngle);

			int newSweepAngle = Pie.SweepAngle;
			this.Pie.SweepAngle = _oldSweepAngle;
			_propSweepAngle.SetValue(Pie, newSweepAngle);

			base.EndEditControlPoints ( );
		}


	}
}
